//
//  BBDiscoverViewController.m
//  QuLuoMianApp
//
//  Created by Sierra on 2017/12/23.
//  Copyright © 2017年 科大讯飞. All rights reserved.
//

#import "BBDiscoverViewController.h"

#import "DiscoverSub1ViewController.h"
#import "DiscoverSub2ViewController.h"
#import "DiscoverSub3ViewController.h"
#import "DiscoverSub4ViewController.h"


#import "WeatherViewController.h"

#import <MapKit/MapKit.h>
#import "MapViewController.h"
//25.3366372782,102.4580883980

@interface BBDiscoverViewController ()<MKMapViewDelegate>


@property (weak, nonatomic) IBOutlet MKMapView *mapView;

@end

@implementation BBDiscoverViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    // 想要跟随用户的位置
    self.mapView.userTrackingMode = MKUserTrackingModeFollow;
    
    // 设置代理
    self.mapView.delegate = self;
    
    // 设置地图的类型
    self.mapView.mapType = MKMapTypeStandard;
    
    // 设置地图中心的经度、纬度
    CLLocationCoordinate2D center = {25.3366372782,102.4580883980};
    // 设置地图显示的范围，地图显示范围越小，细节越清楚
    MKCoordinateSpan span = MKCoordinateSpanMake(0.05,0.05);
    // 创建MKCoordinateRegion对象，该对象代表地图的显示中心和显示范围
    MKCoordinateRegion region =MKCoordinateRegionMake(center, span);
    
    // 设置当前地图的显示中心和显示范围
    [self.mapView setRegion:region animated:YES];

    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jumpToMapVC)];
    [self.mapView addGestureRecognizer:tap];
}

- (void)jumpToMapVC{
    MapViewController * mapVC = [MapViewController new];
    [self.navigationController pushViewController:mapVC animated:YES];
}


- (IBAction)didTapBtnClick:(UIButton *)sender {
    
    switch (sender.tag) {
        case 10:
        {
            DiscoverSub1ViewController * vc = [DiscoverSub1ViewController new];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 20:
        {
            DiscoverSub2ViewController * vc = [DiscoverSub2ViewController new];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 30:
        {
            DiscoverSub3ViewController * vc = [DiscoverSub3ViewController new];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 40:
        {
            DiscoverSub4ViewController * vc = [DiscoverSub4ViewController new];
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
            
        default:
            break;
    }
    
}

- (IBAction)jumpWeatherVC:(id)sender {
    
    WeatherViewController * root = [WeatherViewController new];
    [self.navigationController pushViewController:root animated:YES];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    
    [self.view endEditing:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
